﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GpuSkinning : MonoBehaviour
{
    public GpuAnimation gpuAnimation;

    MeshRenderer meshRenderer;
    MaterialPropertyBlock props;

    // Use this for initialization
    void Start ()
    {
        meshRenderer = gameObject.AddComponent<MeshRenderer>();
        meshRenderer.sharedMaterial = gpuAnimation.material;

        props = new MaterialPropertyBlock();

        gameObject.GetComponentInChildren<SkinnedMeshRenderer>().enabled = false;
    }
	
	// Update is called once per frame
	void Update ()
    {
        props.SetMatrix("_WorldTransform", transform.localToWorldMatrix);
        meshRenderer.SetPropertyBlock(props);
    }
}
